<?php

namespace app\api\validate;

use think\Validate;

class UserValidate extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'id' => 'require|integer|>:0',
        'nickname' => 'max:30',
        'gender' => 'in:1,2',
        'age' => 'integer|between:1,200',
        'height' => 'integer|between:1,300',
        'weight' => 'integer|between:1,300',
        'constellation' => 'in:Aries,Taurus,Gemini,Cancer,Leo,Virgo,Libra,Scorpio,Sagittarius,Capricorn,Aquarius,Pisces',
        'hobby' => 'max:100',
        'province_id' => 'integer|>:0',
        'city_id' => 'integer|>:0',
        'avatar' => 'require',
    ];

    /**
     * 提示消息
     */
    protected $message = [
        'id.require' => 'ID不能为空',
        'id.integer' => 'ID必须为整数',
        'id.>0' => 'ID必须大于0',
        'nickname.require' => '昵称不能为空',
        'nickname.max' => '昵称最多不能超过30个字符',
        'gender.require' => '性别不能为空',
        'gender.in' => '性别格式不正确',
        'age.require' => '年龄不能为空',
        'age.integer' => '年龄必须为整数',
        'age.between' => '年龄只能在1-200之间',
        'height.require' => '身高不能为空',
        'height.integer' => '身高必须为整数',
        'height.between' => '身高只能在1-300之间',
        'weight.require' => '体重不能为空',
        'weight.integer' => '体重必须为整数',
        'weight.between' => '体重只能在1-300之间',
        'constellation.require' => '星座不能为空',
        'constellation.in' => '星座格式不正确',
        'hobby.require' => '兴趣爱好不能为空',
        'hobby.max' => '兴趣爱好最多不能超过100个字符',
        'province_id.require' => '省份不能为空',
        'city_id.require' => '城市不能为空',
        'avatar.require' => '头像不能为空',
    ];

    /**
     * 字段描述
     */
    protected $field = [
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        //修改个人用户信息
        'updateInfo'  => [
            'id' => ['require', 'integer', '>:0'],
            'nickname' => ['max:30'],
            'gender' => ['in:1,2'],
            'age' => ['integer', 'between:1,200'],
            'height' => ['integer', 'between:1,300'],
            'weight' => ['integer', 'between:1,300'],
            'constellation' => ['in:Aries,Taurus,Gemini,Cancer,Leo,Virgo,Libra,Scorpio,Sagittarius,Capricorn,Aquarius,Pisces'],
            'hobby' => ['max:100'],
            'province_id' => ['integer', '>:0'],
            'city_id' => ['integer', '>:0'],
            'avatar' => ['require'],
        ],
    ];

}